import matplotlib.pyplot as plt
import numpy as np
import math

x = np.linspace(1, 6, 201)
yt = []
for t in x:
    yx = math.log(t)
    yt.append(yx)

# Figure for S01, S32 Complete ,S32 Specified and S32 Not a knot
typename = ["01", "32Complete", "32Specified", "32NotAKnot"]
for s in typename:
    filename = "data/ppForm" + s + ".txt"
    with open(filename, 'r') as f:
        lines = f.readlines()
    y = [float(s) for s in lines[0].split()]

    plt.figure()
    plt.plot(x, y, label="y=s(x)")
    plt.plot(x, yt, label="y=lnx", linestyle= '--')
    plt.xlabel("x")
    plt.ylabel("y")
    plt.title("Testing for ppForm S" + s + ".")
    plt.legend()

    figurename = "../report/figure/ppForm" + s + ".png"
    plt.savefig(figurename)
    print("Finish ploting ppForm S" + s + ".")


x = np.linspace(0, 2 * math.pi, 201)
yt = []
for t in x:
    yx = math.sin(t)
    yt.append(yx)

# Figure for S32 Nature and S32 Periodic
typename = ["32Nature", "32Periodic"]
for s in typename:
    filename = "data/ppForm" + s + ".txt"
    with open(filename, 'r') as f:
        lines = f.readlines()
    y = [float(s) for s in lines[0].split()]

    plt.figure()
    plt.plot(x, y, label="y=s(x)")
    plt.plot(x, yt, label="y=sinx", linestyle= '--')
    plt.xlabel("x")
    plt.ylabel("y")
    plt.title("Testing for ppForm S" + s + ".")
    plt.legend()

    figurename = "../report/figure/ppForm" + s + ".png"
    plt.savefig(figurename)
    print("Finish ploting ppForm S" + s + ".")
